<template>
  <div class="commonFuncComp mb16">
    <h3 class="withLine title14" style="margin-bottom:8px;">{{ $t('commonFuns') }}</h3>
    <div class="rightCompMainContBox bdt">
      <a-row :gutter="[8, 16]">
        <a-col
          :span="6"
          class="commonFuncItem"
          v-for="item in lists"
          :key="item.key"
        >
          <auth-button :auth="item.auth" type="info" @click="goTo(item)">
            <table-ellipsis :tableEllipsisIsTurnLine="false" :text="item.title"></table-ellipsis>
          </auth-button>
        </a-col>
      </a-row>
    </div>
  </div>
</template>
<script>
import AuthButton from '@/components/AuthButton'
import TableEllipsis from '@/components/Ellipsis/TableEllipsis'
import { managePerms, softwarePerms, strategyPerms, taskPerms } from '@/config/permission/index'
export default {
  components: {
    AuthButton,
    TableEllipsis
  },
  data () {
    return {
      lists: [{
        // 新建版本
        key: 'ccv',
        title: this.$t('newecuversion'),
        path: '/software/partsSoftwareList',
        auth: softwarePerms.partsSoftware.add
      }, {
        // 新建车辆版本
        key: 'cclbb',
        title: this.$t('newVehicleVersion'),
        path: '/software/vehicleVersion',
        auth: softwarePerms.vehicleVersion.add
      }, {
        // 新建升级策略
        key: 'csj',
        title: this.$t('newsjcl'),
        path: '/strategy',
        auth: strategyPerms.prod.user.fotaSjcl.add
      }, {
        // 新建条件策略
        key: 'ctj',
        title: this.$t('newtjcl'),
        path: '/strategy',
        auth: strategyPerms.prod.user.fotaTjcl.add
      }, {
        // 新建任务
        key: 'crw',
        title: this.$t('buildCampaign'),
        path: '/campaign',
        auth: taskPerms.user.add
      }, {
        // 新建车辆
        key: 'ccl',
        title: this.$t('buildVehicle'),
        path: '/base-data/vehicle',
        auth: managePerms.vehicle2.add
      }, {
        // 导入车辆
        key: 'drcl',
        title: this.$t('importVehicle'),
        path: '/base-data/vehicle',
        auth: managePerms.vehicle2.import
      }, {
        // 新建车型
        key: 'ccx',
        title: this.$t('newVehicleModel'),
        path: '/base-data/car/model',
        auth: managePerms.model.add
      }]
    }
  },
  methods: {
    goTo (data) {
      this.$router.push({
        path: data.path,
        query: {
          action: data.key
        }
      })
    }
  }
}
</script>

<style  lang="less">
.commonFuncComp {
  .rightCompMainContBox {
    padding-bottom: 16px !important;
  }
  .commonFuncItem {
    button,
    .ant-btn[disabled] {
      width: 110px;
      border-radius: 19px;
      height: 32px;
      line-height: 32px;
      cursor: pointer;
      color: #0F0F0F;
    }
    .disabledAuthButtonWrap {
      width: 100%;
      margin-right: 0;
    }
  }
}
</style>
